home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5843 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: string and NULL :ques
  5. Date: 20 Feb 1996 11:04:43 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4gd60bINNk22@keats.ugrad.cs.ubc.ca>
  8. References: <4g5flf$bil@gail.ripco.com>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4g5flf$bil@gail.ripco.com>,
  12. Martin Ambuhl <mambuhl@ripco.com> wrote:
  13.  >If you want to work on a char array which does not contain a null
  14.  >character, how do you propose to tell the library functions where it
  15.  >ends?
  16.  >
  17.  >One possible result of using the library functions on such a char array
  18.  >is a segfault.  On M$BrokenOS, the results are completely unpredictable,
  19.  >since there is no protection against access (including writing) of
  20.  >regions containing other data, your program, or even portions of the OS.
  21.  
  22. Well, even under a good OS, you still can only detect overruns to the accuracy
  23. of a page size. You can still hose your heap, which contains valid addresses
  24. well beyond the bounds of most allocated blocks. In static storage, it is
  25. possible to easily overrun your accesses to one static variable so that you
  26. clobber an adjacent one (or two, or three...). The protection mechanisms
  27. certainly do a great job of catching such errors, and specialized tools which
  28. rely on memory management hardware to some extent (Purify, ElectricFence) do
  29. much of the other half.
  30. -- 
  31.  
  32.